<link rel="stylesheet" href="/static/layuiadmin/style/template.css" media="all">
<style>
    .layadmin-message-fluid .layui-col-md12 {
        padding-bottom: 0px !important;
    }
</style>
<div class="layui-fluid layadmin-message-fluid">
    <div class="layui-row">
        <input type="hidden" name="token" id="token"/>
        <div class="layui-col-md12 layadmin-homepage-list-imgtxt message-content" id="content">

        </div>
        <div class="layui-row message-content-btn">
            <button class="layui-btn" lay-submit lay-filter="formDemo">获取下一页数据</button>
        </div>
    </div>
</div>
<script src="/static/layuiadmin/layui/layui.js"></script>

<script>
    var synchronization = "{:url('query/synchronization')}";
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index', 'form'], function () {
        var form = layui.form,
            $ = layui.$;
        var param = $.param({'page': $("#token").val()});
        $.ajax({
            url: synchronization + '?' + param,
            type: "post",
            success: function (res) {
                var html = "";
                $('#token').val(res.pageToken);
                $.each(res.data, function (i, item) {
                    html += "<div class=\"media-body\">";
                    html += "<a href=\"javascript:;\" class=\"media-left\" style=\"float: left;\">";
                    if (item.imageUrls != null) {
                        html += "<img src=\"" + item.imageUrls[0] + "\" height=\"46px\" width=\"46px\">";
                    } else {
                        html += "<img src=\"/static/layuiadmin/style/res/template/portrait.png\" height=\"46px\" width=\"46px\">";
                    }
                    html += "</a>";
                    html += "<div class=\"pad-btm\">";
                    html += "<p class=\"fontColor\"><a href=\"javascript:;\">" + item.title + "</a></p>";
                    html += "<p class=\"min-font\">";
                    html += " <a href=\"javascript:;\">"+item.state+"</a>\n" +
                        "                            <a href=\"javascript:;\">"+item.city+"</a>\n" +
                        "                            <a href=\"javascript:;\">"+item.district+"</a>";
                    html += "</p>";
                    html += "</div>";
                    html += "  <p class=\"message-text\">地址："+item.address+"</p>";
                    if (item.telephones != null) {
                        html += "  <p class=\"message-text\">电话："+item.telephones+"</p>";
                    }else{
                        html += "  <p class=\"message-text\">电话：未采集到电话</p>";
                    }
                    html += "</div>";
                });
                $('#content').append(html);
            }
        });
        form.on('submit(formDemo)', function (data) {
            var params = $.param({'page': $("#token").val()});
            $.ajax({
                url: synchronization + '?' + params,
                type: "post",
                success: function (res) {
                    var html = "";
                    $('#token').val(res.pageToken);
                    $('#content').html('');
                    $.each(res.data, function (i, item) {
                        html += "<div class=\"media-body\">";
                        html += "<a href=\"javascript:;\" class=\"media-left\" style=\"float: left;\">";
                        if (item.imageUrls != null) {
                            html += "<img src=\"" + item.imageUrls[0] + "\" height=\"46px\" width=\"46px\">";
                        } else {
                            html += "<img src=\"/static/layuiadmin/style/res/template/portrait.png\" height=\"46px\" width=\"46px\">";
                        }
                        html += "</a>";
                        html += "<div class=\"pad-btm\">";
                        html += "<p class=\"fontColor\"><a href=\"javascript:;\">" + item.title + "</a></p>";
                        html += "<p class=\"min-font\">";
                        html += " <a href=\"javascript:;\">"+item.state+"</a>\n" +
                            "                            <a href=\"javascript:;\">"+item.city+"</a>\n" +
                            "                            <a href=\"javascript:;\">"+item.district+"</a>";
                        html += "</p>";
                        html += "</div>";
                        html += "  <p class=\"message-text\">地址："+item.address+"</p>";
                        if (item.telephones != null) {
                            html += "  <p class=\"message-text\">电话："+item.telephones+"</p>";
                        }else{
                            html += "  <p class=\"message-text\">电话：未采集到电话</p>";
                        }
                        html += "</div>";
                    });
                    $('#content').append(html);
                }
            });
        });
    });
</script>